﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        body {
             font-family:Verdana;
             font-size:12px;
        }
        .style1
        {
            width: 80%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <table style="width:95%">
            <tr>
                <td style="width:50%">
                    Table Accounts</td>
                <td style="width:50%; vertical-align:top" rowspan="6">
                        <asp:Button ID="btnNew" runat="server" Text="New" 
                            Width="60px" onclick="btnNew_Click" />
                        <table runat="server" id="optable" class="style1" rules="rows" frame="box">
                        <tr>
                            <td style="text-align: right">CardNo:</td>
                            <td>
                                <asp:TextBox ID="txtCardNo" runat="server"></asp:TextBox>
                                <asp:HiddenField ID="hidID" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right">UserName:</td>
                            <td>
                                <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right">Password:</td>
                            <td>
                                <asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right">Balance:</td>
                            <td>
                                <asp:TextBox ID="txtBalance" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right">&nbsp;</td>
                            <td>
                                <asp:Button ID="btnNE" runat="server" onclick="btnNE_Click" Text="New" 
                                    Width="60px" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <asp:Button ID="btnCancel" runat="server" Text="Cancel" Width="60px" 
                                    onclick="btnCancel_Click" />
                            </td>
                        </tr>
                        </table>
                </td>
            </tr>
            <tr>
                <td style="width:50%">
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                        DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333" 
                        GridLines="None" Width="100%">
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <Columns>
                           <asp:TemplateField HeaderText="序号">
                            <ItemTemplate>
                                 <%#  Container.DataItemIndex+1 %> 
                                </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:BoundField DataField="cardNo" HeaderText="卡号" SortExpression="cardNo" >
                            <ItemStyle HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:BoundField DataField="userName" HeaderText="姓名" 
                                SortExpression="userName" >
                            <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="balance" HeaderText="账户余额" 
                                SortExpression="balance" >
                            <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="修改">
                                <ItemTemplate>
                                    <asp:Button ID="btnEdit" runat="server" Text="修改" 
                                        CommandArgument='<%# Eval("id") %>' onclick="btnEdit_Click" />
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="删除">
                                <ItemTemplate>
                                    <asp:Button ID="btnDelete" runat="server" CommandArgument='<%# Eval("id") %>' 
                                        onclick="btnDelete_Click" onclientclick="return confirm(&quot;确认删除？&quot;);" 
                                        Text="删除" />
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                        </Columns>
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <EditRowStyle BackColor="#999999" />
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    </asp:GridView>
                </td>
            </tr>
            <tr>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td>Table Acountlog</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                        CellPadding="4" DataSourceID="SqlDataSource2" ForeColor="#333333" 
                        GridLines="None" Width="100%">
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <Columns>
                           <asp:TemplateField HeaderText="序号">
                            <ItemTemplate>
                                 <%#  Container.DataItemIndex+1 %> 
                                </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>                        
                            <asp:BoundField DataField="srcCardNo" HeaderText="转出账户" 
                                SortExpression="srcCardNo">
                            <ItemStyle HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:BoundField DataField="desCardNo" HeaderText="转入账户" 
                                SortExpression="desCardNo">
                            <ItemStyle HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:BoundField DataField="amount" HeaderText="金额" SortExpression="amount">
                            <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField DataField="time" HeaderText="转账时间" SortExpression="time">
                            <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                        </Columns>
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <EditRowStyle BackColor="#999999" />
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    </asp:GridView>
                </td>
            </tr>
            <tr>
                <td style="text-align: right">
                    <asp:Button ID="btnRefresh" runat="server" onclick="btnRefresh_Click" 
                        Text="Refresh" />
                </td>
            </tr>
        </table>
    
    </div>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:AccountsConnectionString %>" 
                        SelectCommand="SELECT [id],[cardNo], [userName], [balance] FROM [accounts]">
                    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:AccountsConnectionString %>" 
        SelectCommand="SELECT [id], [srcCardNo], [desCardNo], [amount], [time] FROM [accountlog] ORDER BY [time] DESC">
    </asp:SqlDataSource>
    </form>
</body>
</html>
